/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Form1.java
 *
 * Created on Mar 11, 2011, 2:53:29 PM
 */

package vn.support.ui.frame;

import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JSeparator;
import javax.swing.ListSelectionModel;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;
import org.apache.log4j.Logger;
import vn.support.connection.Connection;
import vn.support.connection.response.processor.ResponseProcessor;
import vn.support.connection.response.processor.impl.StaffChatProcessor;
import vn.support.connection.response.processor.impl.StaffToStaffChatProccessor;
import vn.support.core.dto.DataObject;
import vn.support.core.dto.SessionData;
import vn.support.core.dto.Staff;
import vn.support.core.dto.Visitor;
import vn.support.system.SystemProperties;
import vn.support.ui.ChatView;
import vn.support.ui.action.BrowserAction;
import vn.support.ui.action.RequestAction;

/**
 *
 * @author ADMIN
 */
public final class ContactViewFrame extends AbstractContactView {

    private static final Logger log = Logger.getLogger(ContactViewFrame.class);

    /** Creates new form Form1 */
    public ContactViewFrame() {
        super();
        initComponents();
        this.init();
        this.refresh();
    }

    protected void init() {
        TableClientOnlineModel model = new TableClientOnlineModel();
        jtableOnline.setModel(model);
        jtableOnline.addMouseListener(new MouseAdapter() {
            @Override
            public void mousePressed(MouseEvent e){
                if (e.isPopupTrigger()) {
                    doPop(e);
                }
            }
            @Override
            public void mouseReleased(MouseEvent e){
                if (e.isPopupTrigger()){
                    doPop(e);
                }
            }
            private void doPop(MouseEvent e) {
                int row = jtableOnline.rowAtPoint(e.getPoint());
                ListSelectionModel selectionModel = jtableOnline.getSelectionModel();
                selectionModel.setSelectionInterval(row, row);
                if(jtableOnline.getSelectedRow() != -1) {
                    Visitor visitor = ((TableClientOnlineModel)jtableOnline.getModel()).getVisitor(jtableOnline.getSelectedRow());
                    JPopupMenu menu = createClientPopup(visitor);
                    menu.show(e.getComponent(), e.getX(), e.getY());
                }
            }
        });
        
        jTreeListContact.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                if(e.getClickCount() >= 2) {
                    TreePath path = jTreeListContact.getSelectionPath();
                    Object object = path.getLastPathComponent();
                    if(object instanceof StaffMutableTreeNode) {
                        StaffMutableTreeNode staffNode = (StaffMutableTreeNode)object;
                        Staff staff = (Staff)staffNode.getUserObject();
                        if(staff.isOnline()) {
                            DataObject system = SystemProperties.getData();
                            SessionData session = system.get(SessionData.class.getName());
                            if(!session.getSessionId().equals(staff.getSessionId())) {
                                ChatViewFrame chatView = system.get(ChatView.class.getName() + "#" + staff.getStaffUserName());
                                if(chatView != null) {
                                    chatView.setVisible(true);
                                    return;
                                }
                                DataObject staffToStaffChat = new DataObject(Connection.START_STAFF_TO_STAFF_CHAT_ACTION);
                                staffToStaffChat.set("sessionid", session.getSessionId());
                                staffToStaffChat.set("staffid", staff.getStaffId());
                                staffToStaffChat.set(Staff.class.getName(), staff);
                                staffToStaffChat.set(Connection.RESPONSE_PROCESSOR, new StaffToStaffChatProccessor());
                                connection.execute(staffToStaffChat);
                            }
                        }
                    }
                }
            }
        });

        //Menu
        Action action;
        this.menuFile = new JMenu(bundle("ui.contact.menu.file"));
        action = new AbstractAction(bundle("ui.contact.menu.file.exit")) {
            @Override
            public void actionPerformed(ActionEvent e) {
                ((JFrame)SystemProperties.get(SystemProperties.MAIN_FRAME)).dispose();
                System.exit(0);
            }
        };
        action.putValue(Action.ACCELERATOR_KEY,javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.ALT_MASK));
        ActionManager.set(getClass().getName() + "#menu.file.exit", action);
        menuFile.add(action);
        this.jMenuBar.add(this.menuFile);
        
        this.menuTools = new JMenu(bundle("ui.contact.menu.tools"));
        this.menuToolsLanguage = new JMenu(bundle("ui.contact.menu.tools.language"));
        for(Locale locale : SystemProperties.getSupportedLocale()) {
            final Locale lc = locale;
            String language = "".equals(locale.getDisplayLanguage()) ? "Viet Nam" : locale.getDisplayLanguage();
            action = new AbstractAction(language) {
                @Override
                public void actionPerformed(ActionEvent e) {
                    SystemProperties.setLocale(lc);
                }
            };
            JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem(action);
            if(lc.equals(SystemProperties.getLocale())) {
                menuItem.setSelected(true);
            }
            this.menuToolsLanguage.add(menuItem);
        }
        this.menuTools.add(this.menuToolsLanguage);
        this.jMenuBar.add(this.menuTools);

        this.menuHelp = new JMenu(bundle("ui.contact.menu.help"));
        action = new AbstractAction(bundle("ui.contact.menu.help.about")) {
            @Override
            public void actionPerformed(ActionEvent e) {
                JOptionPane.showMessageDialog(null, bundle("ui.contact.help.about.dialog.message"), bundle("ui.contact.help.about.dialog.title"), JOptionPane.PLAIN_MESSAGE);
            }
        };
        ActionManager.set(getClass().getName() + "#menu.help.about", action);
        menuHelp.add(action);
        this.jMenuBar.add(this.menuHelp);
    }

    @Override
    public void refresh() {
        this.bundle = ResourceBundle.getBundle(UI_BUNDLE);
        //Title
        this.setTitle(bundle("ui.contact.frame.title"));

        //Table model
        TableClientOnlineModel model = new TableClientOnlineModel();
        jtableOnline.setModel(model);

        //Tree model
        DefaultMutableTreeNode root= new DefaultMutableTreeNode(bundle("ui.contact.staff.tree.root"));
        DefaultMutableTreeNode staffMember= new DefaultMutableTreeNode(bundle("ui.contact.staff.tree.staff"));
        //DefaultMutableTreeNode pendingChatNode= new DefaultMutableTreeNode(bundle("ui.contact.staff.tree.chat.pending"));
        StaffTreeModel treeModel = new StaffTreeModel(root);
        treeModel.insertNodeInto(staffMember, root, 0);
        //treeModel.insertNodeInto(pendingChatNode, root, 1);
        this.jTreeListContact.setModel(treeModel);
        this.jTreeListContact.setCellRenderer(new StaffTreeCellRender());
        

        //Menu
        this.menuFile.setText(bundle("ui.contact.menu.file"));
        ActionManager.get(getClass().getName() + "#menu.file.exit").putValue(Action.NAME, bundle("ui.contact.menu.file.exit"));
        ActionManager.get(getClass().getName() + "#menu.help.about").putValue(Action.NAME, bundle("ui.contact.menu.help.about"));
        this.menuTools.setText(bundle("ui.contact.menu.tools"));
        this.menuToolsLanguage.setText(bundle("ui.contact.menu.tools.language"));
        this.menuToolsLanguage.removeAll();
        for(Locale locale : SystemProperties.getSupportedLocale()) {
            final Locale lc = locale;
            String language = "".equals(locale.getDisplayLanguage()) ? "Viet Nam" : locale.getDisplayLanguage();
            Action action = new AbstractAction(language) {
                @Override
                public void actionPerformed(ActionEvent e) {
                    SystemProperties.setLocale(lc);
                }
            };
            JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem(action);
            if(lc.equals(SystemProperties.getLocale())) {
                menuItem.setSelected(true);
            }
            this.menuToolsLanguage.add(menuItem);
        }

        //Status
        this.jLabelStatus.setText(bundle("ui.contact.status.label.status"));
        this.jComboBoxStatus.removeAllItems();
        this.jComboBoxStatus.addItem(bundle("ui.contact.status.1"));
        this.jComboBoxStatus.addItem(bundle("ui.contact.status.2"));
        this.jComboBoxStatus.addItem(bundle("ui.contact.status.3"));
        this.jComboBoxStatus.addItem(bundle("ui.contact.status.4"));
        this.jComboBoxStatus.addItem(bundle("ui.contact.status.5"));
        this.jComboBoxStatus.addItem(bundle("ui.contact.status.6"));
        this.jComboBoxStatus.addItem(bundle("ui.contact.status.7"));
        this.jComboBoxStatus.setSelectedIndex(((Integer)SystemProperties.get(SystemProperties.CURRENT_STATUS)).intValue() - 1);
        this.jLabelCurrentStatus.setText(bundle("ui.contact.status." + SystemProperties.get(SystemProperties.CURRENT_STATUS)));

        this.repaint();
        this.refreshStaff();
        this.refreshVisitor();
    }

    @Override
    public void refreshStaff() {
        TreePath path = this.jTreeListContact.getSelectionPath();
        DefaultMutableTreeNode selectedNode = null;
        if(path != null) {
            selectedNode = (DefaultMutableTreeNode)path.getLastPathComponent();
        }
        long staffId = 0;
        if(selectedNode != null) {
            if(selectedNode instanceof StaffMutableTreeNode) {
                Staff staff = (Staff)selectedNode.getUserObject();
                staffId = staff.getStaffId();
            }
        }

        StaffTreeModel model = (StaffTreeModel)this.jTreeListContact.getModel();
        DefaultMutableTreeNode staffNodes = (DefaultMutableTreeNode)((DefaultMutableTreeNode)model.getRoot()).getChildAt(0);
        staffNodes.removeAllChildren();
        for(Staff staff : this.staffs) {
            if(session.getSessionId().equals(staff.getSessionId())) {
                this.setTitle(bundle("ui.contact.frame.title") + " - " + staff.getStaffName());
            }
            DefaultMutableTreeNode staffNode = new StaffMutableTreeNode(staff);
            staffNodes.add(staffNode);
            if(staff.getStaffId() == staffId) {
                selectedNode = staffNode;
            }
        }
        model.reload(staffNodes);
        this.jTreeListContact.repaint();
        this.jTreeListContact.expandPath(new TreePath(staffNodes.getPath()));
        if(selectedNode != null) {
            this.jTreeListContact.setSelectionPath(new TreePath(selectedNode.getPath()));
        }
    }

    @Override
    public void refreshVisitor() {
        TableClientOnlineModel model = (TableClientOnlineModel) this.jtableOnline.getModel();
        model.refresh(new ArrayList<Visitor>(this.visitors));
    }

    protected JPopupMenu createClientPopup(Visitor visitor) {
        JPopupMenu menu = new JPopupMenu();

        if(visitor.isInComingChat()) {
            DataObject aceptChat = new DataObject(Connection.ACCEPT_CHAT_ACTION);
            aceptChat.set("sessionid", session.getSessionId());
            aceptChat.set("chatsessionid", visitor.getChatSessionId());
            aceptChat.set("visitorsessionid", visitor.getSessionId());
            aceptChat.set(Connection.RESPONSE_PROCESSOR, new StaffChatProcessor());
            RequestAction action = new RequestAction(bundle("ui.contact.visitor.popup.accept"), aceptChat);
            menu.add(action);

            DataObject refuseChat = new DataObject(Connection.REFUSE_CHAT_ACTION);
            refuseChat.set("sessionid", session.getSessionId());
            refuseChat.set("chatsessionid", visitor.getChatSessionId());
            action = new RequestAction(bundle("ui.contact.visitor.popup.refuse"), refuseChat);
            menu.add(action);
        } else if(visitor.isInchat()) {
            final ChatViewFrame chat = SystemProperties.getData().get(ChatView.class.getName() + "#" + visitor.getChatSessionId());
            if(chat != null) {
                menu.add(new AbstractAction(bundle("ui.contact.visitor.popup.join")) {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        chat.setVisible(true);
                    }
                });
            } else {
                DataObject aceptChat = new DataObject(Connection.ACCEPT_CHAT_ACTION);
                aceptChat.set("sessionid", session.getSessionId());
                aceptChat.set("chatsessionid", visitor.getChatSessionId());
                aceptChat.set("visitorsessionid", visitor.getSessionId());
                aceptChat.set(Connection.RESPONSE_PROCESSOR, new StaffChatProcessor());
                RequestAction action = new RequestAction(bundle("ui.contact.visitor.popup.join"), aceptChat);
                menu.add(action);
            }
        } else {
            DataObject forceChat = new DataObject(Connection.PROACTIVE_FORCE_CHAT_ACTION);
            forceChat.set("sessionid", session.getSessionId());
            forceChat.set("visitorsessionid", visitor.getSessionId());
            forceChat.set(Connection.RESPONSE_PROCESSOR, new ResponseProcessor() {
                @Override
                public DataObject process(DataObject data) {
                    return data;
                }
            });
            Action action = new RequestAction(bundle("ui.contact.visitor.popup.forcechat"), forceChat);
            menu.add(action);

            DataObject requestChat = new DataObject(Connection.PROACTIVE_REQUEST_CHAT_ACTION);
            requestChat.set("sessionid", session.getSessionId());
            requestChat.set("visitorsessionid", visitor.getSessionId());
            requestChat.set(Connection.RESPONSE_PROCESSOR, new ResponseProcessor() {
                @Override
                public DataObject process(DataObject data) {
                    return data;
                }
            });
            action = new RequestAction(bundle("ui.contact.visitor.popup.requestchat"), requestChat);
            menu.add(action);
        }

        menu.add(new JSeparator());

        JMenu open = new JMenu(bundle("ui.contact.visitor.popup.open"));
        Action openCurrentPageAction = new BrowserAction(bundle("ui.contact.visitor.popup.open.currentpage"), visitor.getCurrentPage());
        if("".equals(visitor.getCurrentPage()) || visitor.getCurrentPage() == null) {
            openCurrentPageAction.setEnabled(false);
        }
        Action openRefererPageAction = new BrowserAction(bundle("ui.contact.visitor.popup.open.referpage"), visitor.getReferrer());
        if("".equals(visitor.getReferrer()) || visitor.getReferrer() == null) {
            openRefererPageAction.setEnabled(false);
        }
        open.add(openCurrentPageAction);
        open.add(openRefererPageAction);
        menu.add(open);

        menu.add(new JSeparator());
        menu.add(new JMenuItem(bundle("ui.contact.visitor.popup.view.infomation")));
        menu.add(new JMenuItem(bundle("ui.contact.visitor.popup.view.footprint")));
        menu.add(new JMenuItem(bundle("ui.contact.visitor.popup.view.note")));
        menu.add(new JMenuItem(bundle("ui.contact.visitor.popup.view.history")));

        menu.add(new JSeparator());
        menu.add(new JMenuItem(bundle("ui.contact.visitor.popup.addnote")));

        menu.add(new JSeparator());
        menu.add(new JMenuItem(bundle("ui.contact.visitor.popup.ban")));
        return menu;
    }

    private JMenu menuFile;
    private JMenu menuTools;
    private JMenu menuToolsLanguage;
    private JMenu menuHelp;

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jpanelStatus = new javax.swing.JPanel();
        jLabelStatus = new javax.swing.JLabel();
        jComboBoxStatus = new javax.swing.JComboBox();
        jpanelContact = new javax.swing.JPanel();
        jScrollPaneStaff = new javax.swing.JScrollPane();
        jTreeListContact = new javax.swing.JTree();
        jLabelCurrentStatus = new javax.swing.JLabel();
        jPanelOnline = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jtableOnline = new javax.swing.JTable();
        jMenuBar = new javax.swing.JMenuBar();

        setTitle("Login");
        setBackground(new java.awt.Color(176, 203, 246));
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                onWindowClosed(evt);
            }
        });

        jpanelStatus.setBackground(new java.awt.Color(176, 203, 246));
        jpanelStatus.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        jLabelStatus.setText("Status:");

        jComboBoxStatus.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Online", "Offline", "Invisible" }));
        jComboBoxStatus.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jComboBoxStatusItemStateChanged(evt);
            }
        });

        javax.swing.GroupLayout jpanelStatusLayout = new javax.swing.GroupLayout(jpanelStatus);
        jpanelStatus.setLayout(jpanelStatusLayout);
        jpanelStatusLayout.setHorizontalGroup(
            jpanelStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpanelStatusLayout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addComponent(jLabelStatus)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jComboBoxStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(88, Short.MAX_VALUE))
        );
        jpanelStatusLayout.setVerticalGroup(
            jpanelStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpanelStatusLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpanelStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelStatus)
                    .addComponent(jComboBoxStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jpanelContact.setBackground(new java.awt.Color(77, 123, 205));
        jpanelContact.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        jScrollPaneStaff.setViewportView(jTreeListContact);

        jLabelCurrentStatus.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabelCurrentStatus.setForeground(new java.awt.Color(255, 255, 255));
        jLabelCurrentStatus.setText("Curren Status");

        javax.swing.GroupLayout jpanelContactLayout = new javax.swing.GroupLayout(jpanelContact);
        jpanelContact.setLayout(jpanelContactLayout);
        jpanelContactLayout.setHorizontalGroup(
            jpanelContactLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpanelContactLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabelCurrentStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 259, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(34, Short.MAX_VALUE))
            .addComponent(jScrollPaneStaff, javax.swing.GroupLayout.DEFAULT_SIZE, 303, Short.MAX_VALUE)
        );
        jpanelContactLayout.setVerticalGroup(
            jpanelContactLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpanelContactLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabelCurrentStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPaneStaff, javax.swing.GroupLayout.DEFAULT_SIZE, 513, Short.MAX_VALUE))
        );

        jtableOnline.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Chatter ID", "Status", "Deparment", "Operator", "Total Time", "Wait Time", "Current Page", "Country"
            }
        ));
        jScrollPane2.setViewportView(jtableOnline);

        javax.swing.GroupLayout jPanelOnlineLayout = new javax.swing.GroupLayout(jPanelOnline);
        jPanelOnline.setLayout(jPanelOnlineLayout);
        jPanelOnlineLayout.setHorizontalGroup(
            jPanelOnlineLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 886, Short.MAX_VALUE)
            .addGroup(jPanelOnlineLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 886, Short.MAX_VALUE))
        );
        jPanelOnlineLayout.setVerticalGroup(
            jPanelOnlineLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 605, Short.MAX_VALUE)
            .addGroup(jPanelOnlineLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 605, Short.MAX_VALUE))
        );

        setJMenuBar(jMenuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jpanelContact, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jpanelStatus, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanelOnline, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jpanelStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jpanelContact, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addComponent(jPanelOnline, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-1213)/2, (screenSize.height-645)/2, 1213, 645);
    }// </editor-fold>//GEN-END:initComponents

    private void onWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_onWindowClosed
        
    }//GEN-LAST:event_onWindowClosed

    private void jComboBoxStatusItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBoxStatusItemStateChanged
        SystemProperties.set(SystemProperties.CURRENT_STATUS, new Integer(this.jComboBoxStatus.getSelectedIndex() + 1));
        this.jLabelCurrentStatus.setText(bundle("ui.contact.status." + SystemProperties.get(SystemProperties.CURRENT_STATUS)));
        fetchVisitorData.set("status", SystemProperties.get(SystemProperties.CURRENT_STATUS));
        fetchVisitorData.set("randno", System.currentTimeMillis());
        this.connection.execute(this.fetchVisitorData);
    }//GEN-LAST:event_jComboBoxStatusItemStateChanged


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox jComboBoxStatus;
    private javax.swing.JLabel jLabelCurrentStatus;
    private javax.swing.JLabel jLabelStatus;
    private javax.swing.JMenuBar jMenuBar;
    private javax.swing.JPanel jPanelOnline;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPaneStaff;
    private javax.swing.JTree jTreeListContact;
    private javax.swing.JPanel jpanelContact;
    private javax.swing.JPanel jpanelStatus;
    private javax.swing.JTable jtableOnline;
    // End of variables declaration//GEN-END:variables

}


